# Maintainer: ovf <ovf@mm.st>
pkgname=vcmi
pkgver=1.4.2
pkgrel=0
pkgdesc="Open-source engine for Heroes of Might and Magic III"
url="https://vcmi.eu"
# ppc64le, riscv64: no luajit
# game engine
arch="aarch64 x86_64"
license="GPL-2.0-or-later"
makedepends="
	boost-dev
	cmake
	ffmpeg-dev
	fuzzylite-dev
	luajit-dev
	minizip-dev
	onetbb-dev
	qt6-qtbase-dev
	qt6-qttools-dev
	samurai
	sdl2-dev
	sdl2_image-dev
	sdl2_mixer-dev
	sdl2_ttf-dev
	zlib-dev
	"
source="https://github.com/vcmi/vcmi/archive/refs/tags/$pkgver/vcmi-$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja -Wno-dev \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DFORCE_BUNDLED_FL=OFF \
		-DFORCE_BUNDLED_MINIZIP=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
77f9caf1055cae0baee7d2b28a5b893daf569f87a0652acf31bb6294b468d5552cfccf2e3f704954a7bd56909923fbf891c7d3d3d102f2bb008d2fa203de09ea  vcmi-1.4.2.tar.gz
"
